{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Decode Sequencing Run\n",
    "-----------------------------\n",
    "\n",
    "#### Preparation\n",
    "\n",
    "1. Make sure the docker image was started with `./docker.sh -s /path/to/reads`, where `/path/to/reads` is a directory on the same drive as the docker image, which contains the FASTQ files for your sequencing runs. This directory will be mounted within the running image as `/tf/sequencing`.\n",
    "\n",
    "2. Make a new directory called `/tf/primo/data/sequencing/run_id` for this run, where `run_id` is up to you. It must contain two files:\n",
    "\n",
    "    a. `index.csv`: a comma-separated table of metadata for the run. Each row represents an Illumina index (or other identifier) within the run. The first column must be labeled `sequencing_index` and contain this identifier. The rest of the columns are up to you, and contain the properties of the experiment that was given that index.\n",
    "    \n",
    "    b. `location`: a combination python format string / wildcard string that points to the location of all of the FASTQ files for each sequencing index in the run. For instance, if sequencing reads are contained in files like:\n",
    "    ```\n",
    "    /path/to/reads/Run_105/B11_SSC_8m_10x_1_L001-ds.719452199380440faadf49ed854f0cbb/B11-SSC-8m-10x-1_S3_L001_R1_001.fastq.gz\n",
    "    ```\n",
    "    \n",
    "    then `location` would contain the following:\n",
    "    \n",
    "    ```\n",
    "    /tf/sequencing/Run_105/%s_*/*.gz\n",
    "    ```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import subprocess\n",
    "import tempfile\n",
    "import multiprocessing\n",
    "\n",
    "from primo.tools.barcoder import Barcoder"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This is the internal primer (conserved across all reads) which is immediately downstream of the barcode:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "IP = \"AGCACTCAGTATTTGTCCG\""
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This file maps barcodes (which are just sequence numbers 0, 1, 2, etc.) to OpenImages IDs:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "barcode_order = pd.read_csv('/tf/primo/data/metadata/target_barcode_order.csv.gz')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "These parameters (including the random seed) should be the same used for encoding:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "barcoder = Barcoder(\n",
    "    n_data_symbols   = 4,\n",
    "    n_check_symbols  = 2,\n",
    "    bits_per_symbol  = 6,\n",
    "    bases_per_symbol = 5,\n",
    "    seed = 42\n",
    ")\n",
    "def decode_barcode(barcode):\n",
    "    return barcoder.barcode_seq_to_num(barcode.strip())"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This function searches through the reads for a particular sequencing index, looking for exact matches of the internal primer, and collects the barcodes (which are the 30 bases upstream of the internal primer). It then decodes all of the recovered barcodes and returns the count of successful decodes for each barcode:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "def decode_index(path_glob):\n",
    "    \n",
    "    with tempfile.NamedTemporaryFile() as temp:\n",
    "        \n",
    "        if path_glob.endswith(\".gz\"):\n",
    "            cat_cmd = \"zcat %s\" % path_glob\n",
    "        else:\n",
    "            cat_cmd = \"cat %s\" % path_glob\n",
    "    \n",
    "        # extract barcodes\n",
    "        subprocess.call(\n",
    "            (cat_cmd + \"| egrep -o '[ATCGN]{30}%s' | cut -b 1-30 > %s\") % (\n",
    "                IP,\n",
    "                temp.name\n",
    "            ),\n",
    "            shell = True\n",
    "        )\n",
    "        \n",
    "        barcodes = temp.readlines()\n",
    "            \n",
    "    # decode\n",
    "    pool = multiprocessing.Pool()\n",
    "    try:\n",
    "        results = np.array(pool.map(decode_barcode, barcodes))\n",
    "    finally:\n",
    "        pool.close()\n",
    "    \n",
    "    decoded = results[results != None].astype(int)\n",
    "    \n",
    "    counts = np.bincount(decoded, minlength=len(barcode_order))[:len(barcode_order)]\n",
    "    \n",
    "    return counts"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This loops through all of the sequencing indices in a run and builds a pandas data frame with the results:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "def decode_run(run_id):\n",
    "    run_path = '/tf/primo/data/sequencing/%s/' % run_id\n",
    "    \n",
    "    # open run meta\n",
    "    run_meta = pd.read_csv(run_path + 'index.csv')\n",
    "    with open(run_path + 'location') as f:\n",
    "        location = f.readline().strip()\n",
    "        \n",
    "    # decode each index\n",
    "    counts = []\n",
    "    for ix in run_meta.sequencing_index:\n",
    "        print (run_id, ix)\n",
    "        path_glob = location % ix\n",
    "        counts.append(decode_index(path_glob))\n",
    "\n",
    "    # save\n",
    "    df = pd.DataFrame(\n",
    "       np.array(counts),\n",
    "       index = run_meta.sequencing_index,\n",
    "       columns = barcode_order.ImageID\n",
    "    )\n",
    "    df.to_pickle(run_path + 'decoded.pkl.gz')\n",
    "    \n",
    "    return df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The argument here must be a directory in `/tf/primo/data/sequencing` that contains both `index.csv` and `location`, as described at the start of this notebook:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('Run_107', 'G7')\n",
      "('Run_107', 'G11')\n",
      "('Run_107', 'H7')\n",
      "('Run_107', 'H9')\n",
      "('Run_107', 'B9')\n",
      "('Run_107', 'C1')\n",
      "('Run_107', 'D1')\n",
      "('Run_107', 'D10')\n",
      "('Run_107', 'D12')\n"
     ]
    }
   ],
   "source": [
    "df = decode_run(\"Run_107\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "run_meta = (\n",
    "    pd.read_csv('/tf/primo/data/sequencing/Run_105/index.csv')\n",
    ")\n",
    "run_meta = run_meta.set_index(list(run_meta.columns[1:]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "run_meta.join(\n",
    "    df[['e39871fd9fd74f55', 'Randomer']].join(df.sum(1).rename('total')),\n",
    "    on='sequencing_index'\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>ImageID</th>\n",
       "      <th>e39871fd9fd74f55</th>\n",
       "      <th>f18b91585c4d3f3e</th>\n",
       "      <th>ede6e66b2fb59aab</th>\n",
       "      <th>ed600d57fcee4f94</th>\n",
       "      <th>ff47e649b23f446d</th>\n",
       "      <th>e17acd05b631d330</th>\n",
       "      <th>efcfa9654f0e99c5</th>\n",
       "      <th>f4124588a82d57be</th>\n",
       "      <th>f7a1ee2daf06b9e5</th>\n",
       "      <th>e91ca52128724d8e</th>\n",
       "      <th>...</th>\n",
       "      <th>Unused</th>\n",
       "      <th>Unused</th>\n",
       "      <th>Unused</th>\n",
       "      <th>Unused</th>\n",
       "      <th>Unused</th>\n",
       "      <th>Unused</th>\n",
       "      <th>Unused</th>\n",
       "      <th>Unused</th>\n",
       "      <th>Unused</th>\n",
       "      <th>Randomer</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>sequencing_index</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>G7</th>\n",
       "      <td>16</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>42328</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G11</th>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>15911</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H7</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>7</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>3145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H9</th>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>4</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>6518</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B9</th>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>837</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C1</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>4</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>5112</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D1</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>40123</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D10</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>8532</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D12</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2342</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>9 rows × 1600043 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "ImageID           e39871fd9fd74f55  f18b91585c4d3f3e  ede6e66b2fb59aab  \\\n",
       "sequencing_index                                                         \n",
       "G7                              16                 0                 0   \n",
       "G11                              3                 0                 0   \n",
       "H7                               0                 0                 0   \n",
       "H9                               3                 0                 0   \n",
       "B9                               3                 0                 0   \n",
       "C1                               1                 0                 0   \n",
       "D1                               0                 0                 0   \n",
       "D10                              0                 0                 0   \n",
       "D12                              0                 0                 0   \n",
       "\n",
       "ImageID           ed600d57fcee4f94  ff47e649b23f446d  e17acd05b631d330  \\\n",
       "sequencing_index                                                         \n",
       "G7                               0                 0                 0   \n",
       "G11                              0                 2                 0   \n",
       "H7                               0                 0                 0   \n",
       "H9                               4                 0                 0   \n",
       "B9                               0                 1                 0   \n",
       "C1                               1                 1                 2   \n",
       "D1                               0                 0                 0   \n",
       "D10                              1                 0                 3   \n",
       "D12                              0                 0                 1   \n",
       "\n",
       "ImageID           efcfa9654f0e99c5  f4124588a82d57be  f7a1ee2daf06b9e5  \\\n",
       "sequencing_index                                                         \n",
       "G7                               0                 0                 0   \n",
       "G11                              0                 0                 1   \n",
       "H7                               7                 0                 0   \n",
       "H9                               4                 1                 1   \n",
       "B9                               1                 0                 2   \n",
       "C1                               1                 4                 0   \n",
       "D1                               0                 0                 0   \n",
       "D10                              2                 0                 0   \n",
       "D12                              0                 0                 0   \n",
       "\n",
       "ImageID           e91ca52128724d8e    ...     Unused  Unused  Unused  Unused  \\\n",
       "sequencing_index                      ...                                      \n",
       "G7                               0    ...          0       0       0       0   \n",
       "G11                              0    ...          0       0       0       0   \n",
       "H7                               2    ...          0       0       0       0   \n",
       "H9                               0    ...          0       0       0       0   \n",
       "B9                               2    ...          0       0       0       0   \n",
       "C1                               1    ...          0       0       0       0   \n",
       "D1                               0    ...          0       0       0       0   \n",
       "D10                              0    ...          0       0       0       0   \n",
       "D12                              0    ...          0       0       0       0   \n",
       "\n",
       "ImageID           Unused  Unused  Unused  Unused  Unused  Randomer  \n",
       "sequencing_index                                                    \n",
       "G7                     0       0       0       0       0     42328  \n",
       "G11                    0       0       0       0       0     15911  \n",
       "H7                     0       0       0       0       0      3145  \n",
       "H9                     0       0       0       0       0      6518  \n",
       "B9                     0       0       0       0       0       837  \n",
       "C1                     0       0       0       0       0      5112  \n",
       "D1                     0       0       0       0       0     40123  \n",
       "D10                    0       0       0       0       0      8532  \n",
       "D12                    0       0       0       0       0      2342  \n",
       "\n",
       "[9 rows x 1600043 columns]"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "df['Randomer'] / df.sum(1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "df.values[0,:1600000]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "plt.hist(df.values[5,:1600000], log=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'CTGATAGTAGATCATAGATGACACGATGAT'"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "barcoder.num_to_barcode_seq(1600042)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th>ImageID</th>\n",
       "      <th>e39871fd9fd74f55</th>\n",
       "      <th>Randomer</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>sequencing_index</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>G7</th>\n",
       "      <td>16</td>\n",
       "      <td>42328</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>G11</th>\n",
       "      <td>3</td>\n",
       "      <td>15911</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H7</th>\n",
       "      <td>0</td>\n",
       "      <td>3145</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>H9</th>\n",
       "      <td>3</td>\n",
       "      <td>6518</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>B9</th>\n",
       "      <td>3</td>\n",
       "      <td>837</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>C1</th>\n",
       "      <td>1</td>\n",
       "      <td>5112</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D1</th>\n",
       "      <td>0</td>\n",
       "      <td>40123</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D10</th>\n",
       "      <td>0</td>\n",
       "      <td>8532</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>D12</th>\n",
       "      <td>0</td>\n",
       "      <td>2342</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "ImageID           e39871fd9fd74f55  Randomer\n",
       "sequencing_index                            \n",
       "G7                              16     42328\n",
       "G11                              3     15911\n",
       "H7                               0      3145\n",
       "H9                               3      6518\n",
       "B9                               3       837\n",
       "C1                               1      5112\n",
       "D1                               0     40123\n",
       "D10                              0      8532\n",
       "D12                              0      2342"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[['e39871fd9fd74f55', 'Randomer']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.15+"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
